package com.spzx.cart.controller;

import com.spzx.cart.service.CartInfoService;
import com.spzx.common.core.web.domain.AjaxResult;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: atguigu
 * @create: 2025-05-07 15:50
 */

@RestController
public class CartController {


    @Autowired
    private CartInfoService cartInfoService;

    /**
     * 当前登录用户加购
     *
     * @param skuId
     * @param num
     * @return
     */
    @Operation(summary = "当前登录用户加购")
    @GetMapping("/addToCart/{skuId}/{num}")
    public AjaxResult addToCart(
            @PathVariable("skuId") Long skuId,
            @PathVariable("num") Integer num) {
        cartInfoService.addToCart(skuId, num);
        return AjaxResult.success();
    }
}
